<template>
  <div class="components-container">
    <!-- 新增修改 -->
    <sweet-modal ref="dialog" class="dialog" :sweetModalMaxWidth="maxWidth" v-bind:blocking="true">
      <h3>{{title}}</h3>
      <div>
        <fieldset class="layui-elem-field layui-field-title">
          <legend>基本信息</legend>
          <div style="margin:10px 50px;">
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">业务编号</label>  
                <div class="layui-input-inline">
                  <el-input type="text" v-model="prpData.REGBUSNUM" readonly></el-input>
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">逝者姓名</label>
                <div class="layui-input-inline">
                  <el-input type="text" v-model="prpData.REGNAME" :readonly="ischange"></el-input>  
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">逝者年龄</label>
                <div class="layui-input-inline">
                  <el-input type="text" v-model="prpData.REGAGE" :readonly="ischange"></el-input>  
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">逝者性别</label>
                <div class="layui-input-inline">
                  <!-- <el-input type="text" v-model="prpData.REGSEXDESC" :readonly="ischange"></el-input>   -->
                  <el-select v-model="prpData.REGSEX" filterable>
                    <el-option v-for="item in sexType" :key="item.CodeValue" :label="item.CodeName" :value="item.CodeValue">
                    </el-option>
                  </el-select>
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">接尸时间</label>   
                <div class="layui-input-inline chooseTime">
                  <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpData.REGDATE" :readonly="ischange"></el-date-picker>
                  <el-time-picker ref="choosetime" style="width:75px;float:left" clear-icon="null" v-date v-model="prpData.REGTIME" format='HH:mm' :readonly="ischange"></el-time-picker>
                </div>
              </div>
            </div>

            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">接尸地点</label>
                <div class="layui-input-inline">
                  <el-input type="text" v-model=" prpData.REGADDRESS" style="width:770px" :readonly="ischange"></el-input>
                </div>
              </div>
            </div>
            <div class="layui-form-item">

              <div class="layui-inline">
                <label class="layui-form-label">联系人</label>
                <div class="layui-input-inline">
                  <el-input type="text" v-model="prpData.REGHANDLERNAME" :readonly="ischange"></el-input>  
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline">
                  <el-input type="text" v-model="prpData.REGHANDLERLINK" :readonly="ischange"></el-input>
                </div>
              </div>
              <!-- <div class="layui-inline">
              <label class="layui-form-label">逝者关系</label>
              <div class="layui-input-inline">
                <el-input type="text" v-model="prpData.PRPLINKPHONE"></el-input>
              </div>
            </div> -->
            </div>
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-inline">
                  <el-input style="width:770px" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入内容" v-model="prpData.REGREMARK" :readonly='this.title === "洽谈接待详情"'>
                  </el-input>
                </div>
              </div>
            </div>
          </div>
        </fieldset>
        <fieldset class="layui-elem-field layui-field-title">
          <legend>维护服务项目</legend>
          <div style="margin:10px 50px;">
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label" style="width:110px;">预约火化时间</label>  
                <div class="layui-input-inline chooseTime">
                  <el-date-picker style="width:115px;float:left;" clear-icon="null" type="date" v-date v-model="prpDatas.REGAPPOINTMENTCREDATE" :readonly="isinfo"></el-date-picker>
                  <el-time-picker ref="choosetime" style="width:75px;float:left" clear-icon="null" :default-value="timeDefaultShow" v-date v-model="prpDatas.REGAPPOINTMENTCRETIME" format='HH:mm' :readonly="isinfo"></el-time-picker>
                </div>
              </div>
              <div class="layui-inline" v-if="isshowthree">
                    <label class="layui-form-label">火化炉</label>
                    <div class="layui-input-inline">
                        <el-select v-model="prpDatas.REGCRETYPE" filterable>
                            <el-option label="不选择" value="" :disabled="isinfo"></el-option>
                            <el-option v-for="item in hhldata" :key="item.Value" :label="item.Text" :value="item.Value" :disabled="isinfo"></el-option>
                        </el-select>
                    </div>
                </div>
              <div class="layui-inline aaa">
                <el-checkbox v-model="prpDatas.REGISNEEDCOLD" :disabled="isinfo">是否需要冷藏</el-checkbox>  
              </div>
              <div class="layui-inline aaa">
                <el-checkbox v-model="prpDatas.REGISNEEDDEPOSIT" :disabled="isinfo">是否需要寄存</el-checkbox>
              </div>
              <!-- <div class="layui-inline aaa">
                <el-checkbox v-model="prpDatas.PRPISCREMATION" :disabled="isinfo">是否火化炉</el-checkbox>
              </div> -->
            </div>
          </div>
        </fieldset>
        <fieldset class="layui-elem-field layui-field-title">
          <legend>费用项目</legend>
         <div :style="{maxHeight:maxHeight+'px'}">
          <table class="layui-table" style="border-spacing: 0;">
            <colgroup>
              <col>
              <col>
              <col>
              <col>
              <!-- <col width="140">
              <col width="150"> -->
              <col>
            </colgroup>
            <thead>
              <tr>
                <th>费用名称</th>
                <th>单位</th>
                <th>数量</th>
                <th>单价</th>
                <th>金额</th>
                <!-- <th>工号</th>
                <th>登记日期</th> -->
                <th>操作</th>
              </tr>
            </thead>
            <div   id="box"  style="overflow-y: scroll;height: 200px; display: block; overflow: overlay;"  ref="scroll" >
            <tbody ref='inputs'>
              <tr class="allRow" v-for="(chl,index) in chlList">
                <td>
                  <el-select @change="chaSelect(index)" ref="select" v-model="chl.CHLCHAID" :disabled="isinfo" clearable @keydown.enter.native="enterEvent(index,0)" filterable :filter-method="chaFilter" @visible-change="reset()">
                    <el-option v-for="item in chaList" :key="item.CHAID" :label="item.CHANAME" :value="item.CHAID">
                    </el-option>
                  </el-select>
                </td>
                <td>
                  <el-input @keydown.enter.native="enterEvent(index,1)" v-model="chl.CHLAUNIT" readonly>
                    <!-- <template slot="append">元</template> -->
                  </el-input>
                  <!-- {{chl.DPTNAME}} -->
                </td>
                <td>
                  <el-input @input="changemoney(index,$event)" @keydown.enter.native="enterEvent(index,2)" v-model="chl.CHLNUM" :readonly="isinfo">
                    <!-- <template v-if="chl.CHLAUNIT" slot="append">{{chl.CHLAUNIT}}</template> -->
                  </el-input>
                </td>
                <td>
                  <el-input  @input="changechlmoney(index,$event)" @keydown.enter.native="enterEvent(index,3)" v-model="chl.CHLMONEY" :readonly="chl.CHALOGO === 'A'">
                    <template slot="append">元</template>
                  </el-input>
                </td>
                <td>
                  <el-input @keydown.enter.native="enterEvent(index,4)" v-model="chl.CHLMOUNT" :readonly="isinfo">
                    <template slot="append">元</template>
                  </el-input>
                </td>
              
                <td>
                  <button class="layui-btn layui-btn-small layui-btn-normal" @click="remove(index)" :disabled="isinfo">
                    <i class="layui-icon">&#xe640;</i>
                  </button>
                </td>

              </tr>
            </tbody>
            <tfoot>
              <tr>
                <td colspan="1">
                  <span>合计</span>
                </td>
                <td>
                </td>
                <td></td>
                <td></td>
                <td>{{ discountTotal }}</td>
                <!-- <td></td>
                <td></td> -->
                <td>
                  <button class="layui-btn layui-btn-small layui-btn-normal" @click="insert()" :disabled="isinfo">
                    <i class="layui-icon">&#xe654;</i>
                  </button>
                </td>
              </tr>
            </tfoot>
            </div>
          </table>
            </div>
        </fieldset>
      </div>
      <div class="layui-form-item btnCenter">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" :loading="this.$store.state.isloading" @click="submit" v-if="this.title !== '洽谈接待详情'">提交</el-button>
      </div>
    </sweet-modal>

    <depositAdd ref="depositAdd"></depositAdd>
    <printPdf ref="prints"></printPdf>
  </div>
</template>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.aaa .el-checkbox .el-checkbox__label {
    font-size: 18px;
}
  .layui-table tr{
    display: table;
    -moz-display: table;
    width: 100%;
    table-layout: fixed;
  }
</style>
<script>
import apiBase from "@/api/apiBase.js";
import sweetModal from "@/components/sweetModal";
import printPdf from "@/components/Pdf/Print";
import { manage } from "@/mixins/managePage.js";
import {
    formatDate,
    timeStringToDate,
    dateStringToDate
} from "@/utils/date.js";
import { PRPORDER, ORDER } from "@/const/orderConst.js";
import depositAdd from "../businessHall/depositAdd";
import { accMul, Subtr, accAdd } from "@/utils/operations.js";

export default {
    mixins: [manage],
    data() {
        return {
            order: null,
            maxWidth: 1100,
            maxHeight: 300,
            title: null,
            addsInfo: {},
            commonAddr: [], //接尸地点
            ids: null,
            prp: null,
            isinfo: null,
            isshowthree: null,
            hhldata: [],//火化炉

            chl: {
                CHLCHAID: '', //名称
                CHLAUNIT: null, //单位
                CHLNUM: null, //数量
                CHLMONEY: null, //单价
                CHLMOUNT: null, //金额
                CHLDISCOUNT: null,
                CHLDM: null,
                CHLHIDISCOUNT: null,
                CHLJMHIMONEY: null,
                CHLJMMONEY: null,
                CHLNAME: null,
                CHLPRICE: null
                //  CHLACCOUNT: null, //工号
                //  CHLDATE: null,//等级日期
            },

            checked: null,
            //收费项目
            chlList: [],
            chaList: [],

            //编码
            sexType: [], //逝者性别
            prpData: {},
            prpDatas: {
                REGAPPOINTMENTCREDATE: null, //预约火化日期
                REGAPPOINTMENTCRETIME: null, //预约火化时间
                REGISNEEDCOLD: false, //是否冷藏
                REGISNEEDDEPOSIT: false, //是否寄存
                // PRPISCREMATION: false, //是否火化炉
                REGCRETYPE: null,//火化炉类型
            },
            ischange: false,
            timeDefaultShow: [new Date(0,0)],
        };
    },
    methods: {
        //禁用已选项
    //   disabled(chaID) {
    //     let retVal = this.chlList.some(item => {
    //       return item.CHLCHAID === chaID;
    //     });
    //     return retVal;
    //      },
        open(order, id, prpid,REGCURSTATUS,row) {
            this.order = order;
            this.ids = id;
            this.prp = prpid;
            this.ischange = true;
            this.getSexType();
            // this.maxHeight = window.innerHeight - 240;
            switch (this.order) {
                case PRPORDER.ADD:
                    this.dataInfo(prpid);
                    this.dataRepeat();
                    this.insert();
                    this.title = "洽谈接待新增";
                    this.isinfo = false;
                    this.initSelectData(); //初始化下拉框
                    this.prpDatas.REGAPPOINTMENTCREDATE = new Date();
                    this.$refs.dialog.open();
                    break;
                case PRPORDER.MODIFY:
                    this.title = "洽谈接待修改";
                    this.isinfo = false;
                    this.dataRepeat();
                    if(REGCURSTATUS == 'A'){
                      this.ischange = false;
                    }else if(!row.REGLBPRPID && !row.REGCARDNO){
                      this.ischange = false;
                    }
                    // this.dataInfo(prpid);
                    this.talkoverdataInfo(id);
                    this.initSelectData();
                    // this.chlList = [];
                    this.$refs.dialog.open();
                    break;
                case PRPORDER.INFO:
                    this.title = "洽谈接待详情";
                    this.isinfo = true;
                    this.dataRepeat();
                    // this.dataInfo(prpid);
                    this.talkoverdataInfo(id);
                    this.initSelectData();
                    this.$refs.dialog.open();
                    break;
                default:
            }
        },
        //选择收费项目
        chaSelect(index) {
            let chl = this.chlList[index];
            let cha = this.getChaByID(chl.CHLCHAID);
            if (cha) {
                chl.CHLAUNIT = cha.CHAAUNIT;
                chl.CHLMONEY = cha.CHAMONEY;

                chl.CHLCHAID = cha.CHAID;
                chl.CHLDISCOUNT = cha.CHADISCOUNT;
                chl.CHLDM = cha.CHADM;
                chl.CHLHIDISCOUNT = cha.CHAHIDISCOUNT;
                chl.CHLJMHIMONEY = cha.CHAJMHIMONEY;
                chl.CHLJMMONEY = cha.CHAJMMONEY;
                chl.CHLNAME = cha.CHANAME;
                chl.CHLPRICE = cha.CHAPRICE;
                chl.CHLNUM = 1;
                chl.CHLMOUNT = cha.CHAMONEY;
            }
        },
        //获取性别
        getSexType() {
            let data = {};
            apiBase.DoService(data, apiBase.getApiAdress().Code.GetSex, res => {
                this.sexType = res.data.content;
            });
        },
        //ID获取收费项目
        getChaByID(chaId) {
            for (var i in this.allCharge) {
                var cha = this.allCharge[i];
                if (cha.CHAID === chaId) {
                    return cha;
                }
            }
        },
        //计算金额
        changemoney(index, num) {
            let chl = this.chlList[index];
            chl.CHLMOUNT = Number(num) * Number(chl.CHLMONEY);
        },
        changechlmoney(index, money){
            let chl = this.chlList[index];
            chl.CHLMOUNT = Number(chl.CHLNUM) * Number(money);
        },
        //回车事件
        enterEvent(rowNum, colNum) {
            //获取所有行
            let rows = this.$refs.inputs.getElementsByClassName("allRow");
            //获取当前行
            let currow = rows[rowNum];
            // 获取当前行所有列
            let inputs = currow.getElementsByTagName("input");
            //强制隐藏下拉框
            if (colNum === 0) {
                let chl = this.chlList[rowNum];
                if (chl.CHLCHAID.length === 0) {
                    this.$message({
                        type: "error",
                        message: `第${parseInt(rowNum) + 1}行收费项目不能为空!`
                    });
                    return;
                }
                let select = this.$refs.select;
                select[rowNum].visible = false;
            }
            //最后一列
            if (colNum === inputs.length - 1) {
                //最后一行
                if (rowNum === this.chlList.length - 1) {
                    //插入空行
                    if (!this.insert()) {
                        return;
                    }
                }
                //换行
                this.$nextTick(function() {
                    this.enterEvent(rowNum + 1, -1);
                });
            } else {
                //获取下一个焦点
                this.$nextTick(function() {
                    inputs[colNum + 1].select();
                });
            }
        },
        remove(index) {
            this.chlList.splice(index, 1);
        },
        //收费项目
        getAllCharge() {
            let data = {
               SOURCE: '业务洽谈'
            };
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Checkout.GetChargeBySource,
                res => {
                    this.allCharge = res.data.content;
                    this.chaList = JSON.parse(JSON.stringify(this.allCharge));
                }
            );
        },
        //获取预约火化炉类型
        GetCreationStatus() {
            let data = {};
            apiBase.DoService(
                data,
                // apiBase.getApiAdress().Reserve.GetPrpCreationStatus,
                apiBase.getApiAdress().Code.GetCremationType,
                res => {
                    let creTypeData = res.data.content,
                        legendsCreData = creTypeData.map(item => ({
                            Text: item.CodeName,
                            Value: item.CodeValue
                        }));
                    this.hhldata = legendsCreData;
                }
            );
        },
        //自定义筛选
        chaFilter(val) {
        const PinyinMatch = require('pinyin-match');
        if (val) {
            var result = []
            this.allCharge.forEach(i => { 
                var m = PinyinMatch.match(i.CHANAME, val)
                if (m) {
                    result.push(i);
                }
            })
            this.chaList = result;
        }else{
            this.chaList = this.allCharge;
        }
        },
        reset() {
            this.chaList = JSON.parse(JSON.stringify(this.allCharge));
        },
        //新增行
        insert() {
        if(this.chlList.length == 0){
          this.chlList.push(JSON.parse(JSON.stringify(this.chl)));
        }else{
            for (let index in this.chlList) {
                let chl = this.chlList[index];
                if (chl.CHLCHAID.length === 0) {
                    this.$message({
                        type: "error",
                        message: `第${parseInt(index) + 1}行收费项目不能为空!`
                    });
                    return false;
                  }
                 }
               this.chlList.push(JSON.parse(JSON.stringify(this.chl)));    
            }
         setTimeout(() => {
            let tableHeight = this.$refs.scroll.scrollHeight;
            $("#box").animate({scrollTop:tableHeight},500);
        }, 100);
        return true;
      },

        //初始化下拉框数据
        initSelectData() {
            this.getAllCharge();
            this.GetCreationStatus();
        },
        //提交
        submit() {
            switch (this.order) {
                case PRPORDER.ADD:
                    this.dataAdd();
                    break;
                case PRPORDER.MODIFY:
                    this.dataModify();
                    break;
                default:
            }
        },
        closeDialog() {
            this.$refs.dialog.close();
        },

        dataAdd() {
            // prpData.REGREMARK  备注字段  
            let Data = JSON.parse(JSON.stringify(this.prpDatas));
            let chlList = JSON.parse(JSON.stringify(this.chlList));
            if (Data.REGISNEEDCOLD === false) {
                Data.REGISNEEDCOLD = "A";
            } else {
                Data.REGISNEEDCOLD = "B";
            }
            if (Data.REGISNEEDDEPOSIT === false) {
                Data.REGISNEEDDEPOSIT = "A";
            } else {
                Data.REGISNEEDDEPOSIT = "B";
            }
            // if (Data.PRPISCREMATION === false) {
            //     Data.PRPISCREMATION = "A";
            // } else {
            //     Data.PRPISCREMATION = "B";
            // }
            Data.REGID = this.ids;
            Data.PRPID = this.prp;
            Data.REGAPPOINTMENTCREDATE = formatDate(
                Data.REGAPPOINTMENTCREDATE,
                "yyyyMMdd"
            );
            if(Data.REGAPPOINTMENTCRETIME){
              Data.REGAPPOINTMENTCRETIME =
                formatDate(Data.REGAPPOINTMENTCRETIME, "hhmm") + "00";
            }
            if (chlList.length > 0) {
                chlList.forEach((item,index) => {
                    if(item.CHLCHAID == ""){
                        chlList.splice(index,1);
                    }
                });
                Data.List_Chl = chlList;
            };
            Data.REGREMARK = this.prpData.REGREMARK;
            apiBase.DoService(
                Data,
                apiBase.getApiAdress().TalkOver.Create,
                res => {
                    this.addsInfo = res.data.content;
                    // this.$confirm("是否打印派车单?", "新增成功", {
                    //   confirmButtonText: "打印",
                    //   cancelButtonText: "不打印",
                    //   type: "warning"
                    // })
                    //   .then(() => {
                    //     this.$refs.prints.open("打印派车单", this.addsInfo.PRPID, null);
                    //   })
                    //   .catch(() => {
                    //     this.$message({
                    //       type: "success",
                    //       message: "新增成功!"
                    //     });
                    //     this.refreshData();
                    //   });
                    this.$message({
                        type: "success",
                        message: "新增成功!"
                    });
                    this.$refs.dialog.close();
                    this.refreshData();
                },
                res => {
                    this.$message.error(res.data.msg);
                }
            );
        },
        //登记修改
        dataModify() {
            let Data = JSON.parse(JSON.stringify(this.prpDatas));
            let chlList = JSON.parse(JSON.stringify(this.chlList));
            if (Data.REGISNEEDCOLD === false) {
                Data.REGISNEEDCOLD = "A";
            } else {
                Data.REGISNEEDCOLD = "B";
            }
            if (Data.REGISNEEDDEPOSIT === false) {
                Data.REGISNEEDDEPOSIT = "A";
            } else {
                Data.REGISNEEDDEPOSIT = "B";
            }
            // if (Data.PRPISCREMATION === false) {
            //     Data.PRPISCREMATION = "A";
            // } else {
            //     Data.PRPISCREMATION = "B";
            // }
            if(Data.REGAPPOINTMENTCREDATE){
              Data.REGAPPOINTMENTCREDATE = formatDate(
                  Data.REGAPPOINTMENTCREDATE,
                  "yyyyMMdd"
              );
            }else{
              Data.REGAPPOINTMENTCREDATE = ''
            }
            if(Data.REGAPPOINTMENTCRETIME){
              Data.REGAPPOINTMENTCRETIME =
                formatDate(Data.REGAPPOINTMENTCRETIME, "hhmm") + "00";
            }else{
              Data.REGAPPOINTMENTCRETIME = ''
            }
            if (chlList.length > 0) {
                chlList.forEach((item,index) => {
                    if(item.CHLCHAID == ""){
                        chlList.splice(index,1);
                    }
                });
                Data.List_Chl = chlList;
            };
            Data.REGREMARK = this.prpData.REGREMARK;
            Data.REGNAME = this.prpData.REGNAME;
            Data.REGAGE = this.prpData.REGAGE;
            Data.REGSEX = this.prpData.REGSEX;
            Data.REGDATE = formatDate(
                this.prpData.REGDATE,
                "yyyyMMdd"
            );
            Data.REGTIME = formatDate(this.prpData.REGTIME, "hhmm") + "00";
            Data.REGADDRESS = this.prpData.REGADDRESS;    
            Data.REGHANDLERNAME = this.prpData.REGHANDLERNAME;
            Data.REGHANDLERLINK = this.prpData.REGHANDLERLINK;

            Data.REGID = this.ids;
            Data.PRPID = this.prp;
            apiBase.DoService(
                Data,
                apiBase.getApiAdress().TalkOver.Modify,
                res => {
                    this.$refs.dialog.close();
                    this.$message({
                        type: "success",
                        message: "修改成功!"
                    });
                    this.refreshData();
                },
                res => {
                    this.$message.error(res.data.msg);
                }
            );
        },
        //洽谈个人信息详情
        dataInfo(id) {
            let Data = {
                PRPID: id
            };
            apiBase.DoService(
                Data,
                apiBase.getApiAdress().Reserve.DetailPhoneReserve,
                res => {
                    this.prpData = res.data.content;
                    // this.prpData.PRPLINSTRTIME = timeStringToDate(
                    //     res.data.content.PRPLINSTRTIME
                    // );

                    // this.prpData.REGAPPOINTMENTCRETIME = timeStringToDate(this.prpData.REGAPPOINTMENTCRETIME);
                    // this.prpData.PRPLINNAME = this.prpData.PRPLINNAME;
                    this.prpDatas.REGAPPOINTMENTCREDATE = res.data.content.PRPCREMATIONDATEDESC;
                    this.prpDatas.REGCRETYPE = res.data.content.PRPCREMATION;      
                    // this.prpDatas.REGAPPOINTMENTCRETIME = res.data.content.PRPCREMATIONTIMEDESC; 
                      
                    this.prpDatas.REGAPPOINTMENTCRETIME = timeStringToDate(
                        res.data.content.PRPCREMATIONTIMEDESC
                    );
                    this.prpData.PRPWORKTIME = timeStringToDate(
                        this.prpData.PRPWORKTIME
                    );

                }
            );
        },
        //洽谈维护服务项目详情
        talkoverdataInfo(id) {
            let Data = {
                REGID: id
            };
            apiBase.DoService(
                Data,
                apiBase.getApiAdress().TalkOver.Detail,  
                res => {
                    // this.prpDatas = res.data.content;
                    this.prpData = res.data.content;
                    this.prpData.REGTIME = timeStringToDate( this.prpData.REGTIME );
                    if(res.data.content.Chl === null){
                        this.chlList = [];
                    }else{
                        this.chlList = res.data.content.Chl;
                    }
                    this.prpDatas.REGAPPOINTMENTCREDATE = dateStringToDate(
                        res.data.content.REGAPPOINTMENTCREDATE
                    );
                    this.prpDatas.REGAPPOINTMENTCRETIME = timeStringToDate(
                        res.data.content.REGAPPOINTMENTCRETIME
                    );
                    this.prpDatas.REGCRETYPE = res.data.content.REGCRETYPE;
                    if (res.data.content.REGISNEEDCOLD === "A" || res.data.content.REGISNEEDCOLD === "") {
                        this.prpDatas.REGISNEEDCOLD = false;
                    } else {
                        this.prpDatas.REGISNEEDCOLD = true;
                    }
                    // if (res.data.content.PRPISCREMATION === "A" || res.data.content.PRPISCREMATION === "") {
                    //     this.prpDatas.PRPISCREMATION = false;
                    // } else {
                    //     this.prpDatas.PRPISCREMATION = true;
                    // }
                    if (res.data.content.REGISNEEDDEPOSIT === "A" || res.data.content.REGISNEEDDEPOSIT === "") {
                        this.prpDatas.REGISNEEDDEPOSIT = false;
                    } else {
                        this.prpDatas.REGISNEEDDEPOSIT = true;
                    }
                    if( this.order != ORDER.INFO){
                        this.insert();
                    }
                }
            );
        },

        //数据重置
        dataRepeat() {
            this.prpDatas.REGAPPOINTMENTCREDATE = new Date();
            this.prpDatas.REGAPPOINTMENTCRETIME = null;
            this.chlList = [];
            Object.assign(this.$data.prpDatas, this.$options.data().prpDatas);
            Object.assign(this.$data.prpData, this.$options.data().prpData);
            // this.prpData.PRPCALLDATE = formatDate(new Date(), "yyyy-MM-dd");
        },
        refreshData() {
            this.$emit("refreshData");
        }
    },
    components: {
        sweetModal,
        printPdf,
        depositAdd
    },
    created(){
         apiBase.DoService(
            {},
            apiBase.getApiAdress().Param.GetPrpShowProgram,
            res => {
                let showprp = res.data.content; //预约显示项              
                if (showprp.indexOf("D") > -1) {
                    this.isshowthree = true;
                }
            }
        );
    },
    //计算属性
    computed: {
        discountTotal() {
            let total = 0;
            for (let chl of this.chlList) {
                total = accAdd(total, chl.CHLMOUNT);
            }
            return total;
        }
    },
    watch: {
        discountTotal: function(val) {}
    }
};
</script>

